<template>
    <form class="layui-form" action="">
        <div class="layui-form-item">
            <label class="layui-form-label">用户名</label>
            <div class="layui-input-inline"><input name="username"class="layui-input" type="text" autocomplete="off"></div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">密码</label>
            <div class="layui-input-inline"><input name="password"class="layui-input" type="password" autocomplete="off"></div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">验证码</label>
            <div class="layui-input-inline"><input name="authcode"class="layui-input" type="text" autocomplete="off"></div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit="" lay-filter="login">立即提交</button>
            </div>
        </div>
    </form>
</template>
<script>
    export default{
        name: 'login',
        data: function(){
            return {};
        },
        mounted: function(){
            var me = this;
            layui.use(['form', 'layedit', 'laydate'], function(){
                var form = layui.form;
                
                //监听提交
                form.on('submit(login)', function(data){
                    console.info(data)
                    axios.post('/user', {
                        firstName: 'Fred',
                        lastName: 'Flintstone'
                    }).then(function (response) {
                        console.log(response);
                    }).catch(function (error) {
                        console.log(error);
                    });
                    
                    // me.$ajax({
                    //     method: 'post',
                    //     headers: {
                    //         'X-Requested-With': 'XMLHttpRequest',
                    //         'contentType': 'application/json;charset=utf-8'
                    //     },
                    //     url: 'http://adtest.lehuotl.com/user',
                    //     data: data.field,
                        
                    //     success: function(){

                    //     }
                    // })




                    // layer.alert(JSON.stringify(data.field), {
                    //     title: '用户名 密码'
                    // })
                    return false;
                });
            });
        }
    }
</script>
<style>

</style>

